mini.parse();
var grid = mini.get('datagrid1');
var formListId;
//初始化
$(function(){
	httpRequest();
})
//传参
function SetData(data){
	console.log(data);
	formListId = data.formListId;
}
//确定
function SaveData(){
	var row = grid.getSelected();
	console.log(row);
	$.ajax({
        url: ajaxUrl+ "/activitiFormController/modelAndForm.do",
        type:"POST",
        data: {
        	modelId: row.id,
        	modelName: row.name,
        	formListId: formListId
        },
        success : function(data){
            console.log(data);
            if(data.type == 'sucess'){
            	CloseWindow('close');
            }else{
            	mini.alert(data.msg);
            }
//            var activitiList = data.data;
//            grid.setData(activitiList);
        },
        error : function(data){
            console.log("失败")
        }
    })
}
//关闭子页面
function CloseWindow(action) {
    if (action == "close" && grid.isChanged()) {
        if (confirm("数据被修改了，是否先保存？")) {
            return false;
        }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
}
function onOk(e) {
    SaveData();
}
function onCancel(e) {
    CloseWindow("cancel");
}
//ajax请求
function httpRequest(){
	$.ajax({
        url: ajaxUrl+ "/activitiFormController/modelList.do",
        type:"POST",
        success : function(data){
            console.log(data);
            var activitiList = data.data;
            grid.setData(activitiList);
        },
        error : function(data){
            console.log("失败")
        }
    })
}